package com.wn.equipment.rabbitmq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ author     ：NST
 * @ date       ：Created in 2022/10/19 16:49
 * @ description：消息队列配置类
 * @ modified By：
 * @ version:
 */
@Configuration
public class RabbitmqConfiguration {

    /**
     * @ param
     * @return org.springframework.amqp.core.TopicExchange
     * @ author nst
     * @ date 2022/10/19 16:51
     * @ Description //声明交换机
     */
    @Bean
    public TopicExchange exchangeBookkeeping(){
        return new TopicExchange("exchangeBookkeeping");
    }
    /**
     * @param / 队列名 是否持久化
     * @return org.springframework.amqp.core.Queue
     * @ author nst
     * @ date 2022/10/19 16:52
     * @ Description 声明队列
     */
    @Bean
    public Queue queueeBookkeeping(){
        return new Queue("queueBookkeeping",true);
    }

    /**
     * @ param
     * @return org.springframework.amqp.core.Binding
     * @ author nst
     * @ date 2022/10/19 16:54
     * @ Description 绑定队列到交换机
     */
    @Bean
    public Binding bindingemail(){
        return BindingBuilder.bind(queueeBookkeeping()).to(exchangeBookkeeping()).with("bookkeeping");
    }

    //序列化转换器
    @Bean
    public MessageConverter messageConverter(){
        return new Jackson2JsonMessageConverter();
    }
}
